package com.jack.uikit.utils

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty

/**
 * 委托的方式获取view
 *
 * @author Jack 2021-05-02 22:21
 */
class GetView<V : View>(private val id: Int) : ReadOnlyProperty<RecyclerView.ViewHolder, V> {

    /**
     * @param thisRef 委托所属对象
     */
    override fun getValue(thisRef: RecyclerView.ViewHolder, property: KProperty<*>): V {
        return thisRef.itemView.findViewById(id)
    }

}